{% extends 'base.html' %}
{% block title %}账单管理{% endblock %}

{% block head %}
{{ super() }}
<style>
.billing-container {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin: 0;
    padding: 30px;
}
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}
.page-title {
    font-size: 2rem;
    font-weight: 400;
    color: #333;
    margin: 0;
}
.form-container {
    max-width: 600px;
    margin: 0 auto 2rem auto;
    padding: 2rem;
    background: #f8f9fa;
    border-radius: 10px;
    box-shadow: 0 0 10px rgba(0,0,0,0.05);
}
.form-title {
    color: #2c3e50;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #e9ecef;
    font-size: 1.2rem;
    font-weight: 500;
}
.form-group {
    margin-bottom: 1.5rem;
}
.form-group label {
    font-weight: 500;
    color: #495057;
    margin-bottom: 0.5rem;
}
.form-control:focus, .form-select:focus {
    border-color: #4a90e2;
    box-shadow: 0 0 0 0.2rem rgba(74,144,226,0.25);
}
.btn-submit {
    padding: 0.5rem 1.5rem;
    background-color: #28a745;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    transition: background-color 0.3s ease;
}
.btn-submit:hover {
    background-color: #218838;
}
.billing-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
    background: white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.billing-table th,
.billing-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #e9ecef;
}
.billing-table th {
    background-color: #f8f9fa;
    font-weight: 600;
    color: #495057;
}
.billing-table tbody tr:hover {
    background-color: #f8f9fa;
}
</style>
{% endblock %}

{% block content %}
<div class="billing-container">
    <div class="page-header">
        <h2 class="page-title">账单管理</h2>
    </div>
    <div class="form-container">
        <h3 class="form-title"><i class="fas fa-file-invoice-dollar"></i> 缴费</h3>
        <form method="post">
            <div class="form-group">
                <label for="prescription_id" class="required-field">处方ID号</label>
                <select name="prescription_id" id="prescription_id" class="form-select" required>
                    <option value="">请选择处方</option>
                    {% for pres in prescriptions %}
                    <option value="{{ pres['处方ID'] }}">{{ pres['处方ID'] }}</option>
                    {% endfor %}
                </select>
            </div>
            <div class="form-group">
                <label for="datetime" class="required-field">收费时间</label>
                <input id="datetime" type="datetime-local" name="datetime" class="form-control" required>
            </div>
            <div class="form-group">
                <label for="payment_method" class="required-field">支付方式</label>
                <select name="payment_method" id="payment_method" class="form-select" required>
                    <option value="现金">现金</option>
                    <option value="银行卡">银行卡</option>
                    <option value="信用卡">信用卡</option>
                    <option value="支付宝">支付宝</option>
                    <option value="微信">微信</option>
                    <option value="医保卡">医保卡</option>
                </select>
            </div>
            <button type="submit" class="btn-submit">添加</button>
        </form>
    </div>
    <h3 class="form-title"><i class="fas fa-list"></i> 账单</h3>
    <table class="billing-table">
        <thead>
            <tr>
                <th>账单ID</th>
                <th>处方ID</th>
                <th>病人</th>
                <th>总金额</th>
                <th>支付方式</th>
            </tr>
        </thead>
        <tbody>
            {% for bill in bills %}
            <tr>
                <td>{{ bill['收费ID'] }}</td>
                <td>{{ bill['处方ID'] }}</td>
                <td>{{ bill['病人姓名'] }}</td>
                <td>{{ bill['收费金额'] }}</td>
                <td>{{ bill['支付方式'] }}</td>
            </tr>
            {% endfor %}
        </tbody>
    </table>
    <br>
    <h3 class="form-title"><i class="fas fa-list"></i> 待缴费处方</h3>
    <table class="billing-table">
        <thead>
            <tr>
                <th>处方ID</th>
                <th>病人姓名</th>
                <th>医生姓名</th>
                <th>开具时间</th>
                <th>诊断结果</th>
                <th>待缴费金额</th>
            </tr>
        </thead>
        <tbody>
            {% for un_pre in unpaid_pres %}
            <tr>
                <td>{{ un_pre['处方ID'] }}</td>
                <td>{{ un_pre['病人姓名'] }}</td>
                <td>{{ un_pre['医生姓名'] }}</td>
                <td>{{ un_pre['开具时间'] }}</td>
                <td>{{ un_pre['诊断结果'] }}</td>
                <td>{{ un_pre['待缴费金额'] }}</td>
            </tr>
            {% endfor %}
        </tbody>
    </table>
</div>
{% endblock %}
